import 'package:flutter_base/utils/loading/loading_utils.dart';

import '../http_response.dart';

extension FutureExtensionToast on Future<HttpResponse> {
  Future<HttpResponse> toast() {
    return then((response) {
      if (response.isSuccess != true && response.message?.isNotEmpty == true) {
        LoadingUtils.showToast(response.message);
      }
      return Future.value(response);
    }, onError: (error) {
      HttpResponse err = error;
      LoadingUtils.showToast(err.message);
      return Future.error(error);
    });
  }
}
